import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MatLabelVO, MatLabelForm, MatLabelQuery } from '@/api/wmscloud/matLabel/types';

/**
 * 查询物料标签列表
 * @param query
 * @returns {*}
 */

export const listMatLabel = (query?: MatLabelQuery): AxiosPromise<MatLabelVO[]> => {
  return request({
    url: '/wmsCloud/matLabel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料标签列表（弹窗）
 * @param query
 * @returns {*}
 */

export const listMatLabelDialog = (query?: MatLabelQuery): AxiosPromise<MatLabelVO[]> => {
  return request({
    url: '/wmsCloud/matLabel/listDialog',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料标签详细
 * @param labelId
 */
export const getMatLabel = (labelId: string | number): AxiosPromise<MatLabelVO> => {
  return request({
    url: '/wmsCloud/matLabel/' + labelId,
    method: 'get'
  });
};

/**
 * 新增物料标签
 * @param data
 */
export const addMatLabel = (data: MatLabelForm) => {
  return request({
    url: '/wmsCloud/matLabel',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料标签
 * @param data
 */
export const updateMatLabel = (data: MatLabelForm) => {
  return request({
    url: '/wmsCloud/matLabel',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料标签
 * @param labelId
 */
export const delMatLabel = (labelId: string | number | Array<string | number>) => {
  return request({
    url: '/wmsCloud/matLabel/' + labelId,
    method: 'delete'
  });
};

/**
 * 打印物料标签
 * @param labelId
 */
export const printMatLabel = (labelId: string | number )=> {
  return request({
    url: '/wmsCloud/matLabel/printMatLabel/' + labelId,
    method: 'get',
    responseType: 'arraybuffer',
    headers: {
      'Content-Type': 'application/json'
    },
  })
}

/**
 * 批量打印物料标签
 * @param labelIds
 */
export const printMatLabelBatch = (labelIds: string | number | Array<string | number> )=> {
  return request({
    url: '/wmsCloud/matLabel/printMatLabelBatch/' + labelIds,
    method: 'get',
    responseType: 'arraybuffer',
    headers: {
      'Content-Type': 'application/json'
    },
  })
}
